package com.zyg.dao.impl;

import com.zyg.dao.AccountDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.NestedRuntimeException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("accountDao")
public class AccountDaoImpl implements AccountDao{

	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	public void transfer(String outUser,String inUser,Double money) throws Exception{

		System.out.println("transfer....");
		jdbcTemplate.update("update account set balance=balance-? where username=?", money, outUser);
		//int a = 1/0;
		jdbcTemplate.update("update account set balance=balance+? where username=?",money,inUser);
		System.out.println( "转账成功！" );
	}
}
